<!DOCTYPE html>
<!-- <html xmlns:th="http://www.thymeleaf.org"> -->
<head>
<meta charset="utf-8">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<title></title>
<script type="text/javascript" src="../js/jquery-2.1.1.min.js"></script>
<link rel="stylesheet" href="../js/layui/css/layui.css">
<script src="../js/layui/layui.all.js" type="text/javascript"></script>
<script type="text/javascript" src="../js/WebCalendar.js"></script>
<script type="text/javascript">
	
$(function (){
	checkseach();
	//location.reload();
})
var tabobj;
	function checkseach(){
	
		
		 layui.use(['form','layer', 'table'], function(){
			 
			  var laydate = layui.laydate //日期
			  ,layer = layui.layer //弹层
			  ,table = layui.table //表格
			 ,form = layui.form;
			   if( btime !="" && etime != ""){
					  if(btime > etime || btime == etime){
					  	layer.msg("时间区间输入不规范，请重新输入");
					  	return;
					  }
					  	  
				  } 
				//执行渲染
				tabobj =  table.render({
				    elem: '#asktab'
				    ,url:"selAllAskers"
				    ,method:'post',
				    page:true,
				    where:{
				    }
				   ,width:1700
				    ,height: 715 //容器高度
				    ,cols:  [[ //标题栏
				        {checkbox: true,}
				        ,{field: 'askerId', title: 'ID', width: 80}
				        ,{field: 'askerName', title: '员工名', width: 100}
				        ,{field: 'checkState', title: '签到状态', width: 100}
				        ,{field: 'changeState', title: '分配', width: 100}
				        ,{field: 'weight', title: '权重', width: 100}
				        ,{field: 'checkInTime', title: '签到时间', width: 140}
				        ,{field: 'roleName', title: '角色名', width:70}
				        ,{field: 'bakContent', title: '备注', width: 140}
				        ,{fixed: 'right', width:100, title: '操作',align:'center', toolbar: '#barDemo'}
				      ]]
				  });
		 })
		// location.reload()
	}
	
	var askid;
	 layui.use(['form','layer', 'table'], function(){
		 
		  var laydate = layui.laydate //日期
		  ,layer = layui.layer //弹层
		  ,table = layui.table //表格
		 ,form = layui.form;
		//监听工具条
		  table.on('tool(demo)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
		    var data = obj.data //获得当前行数据
		    ,layEvent = obj.event; //获得 lay-event 对应的值
			
		    askid = data.askerId;
		    
		    if(layEvent === 'bjqz'){
		    	 layer.open({
		    		 title:'修改员工权重',
						area:['400px','500px'],
						//closeBtn:0,
						type:1,
						content:$("#askdiv"),
						end : function(){

			         		   // alert("你点击了右上角的X");
							$("#askdiv").hide();
			         		}
		    	 })
		    }
		  })
	 })
	function askclosebtn(){
		 layer.closeAll();
		 $("#askdiv").hide();
	 }
	 function updseachBtn(){
		 var weight = #("#weight").val();
		 var bzu = #("#bzu").val();
		 var reg = /^[0-9]*$/;
 		if(!reg.test(weight)){
 			layer.msg("权重输入格式错误");
 			return;
 		}
 		if(weight!="" && bzu !=""){
 			layer.confirm('确认修改么', function(index){
		    	  layer.close(index);
		 		   $.ajax({
		 			   url:"updAskersWeiht",
		 			   type:"post",
		 			   data:{
		 				  askerId  : askid,
		 				 weight  : weight,
		 				bakContent  : bzu
		 			   },
		 			   dataType:"json",
		 			   success:function(res){
		 				   if(res.success){
		 					  layer.msg(res.message);
		 					  layer.closeAll('page');
		 		    			  tabobj.reload();
		 				   }else{
		 					  layer.msg(res.message);
		 					 layer.closeAll('page');
		 		    			  tabobj.reload();
		 				   }
		 			   }
		 		   })
		      });
 		}else{
 			layer.msg("权重的备注都不能为空");
 			return;
 		}
	 }
</script>
<script type="text/html" id="barDemo">
	<a class="layui-btn layui-btn-xs" lay-event="bjqz">编辑权重</a>
</script>
</head>
<body>
<table id="asktab" lay-filter="demo"></table>
	
	<!-- 修改窗体  -->
 <div id="askdiv" style="display: none;">
		<form class="layui-form"  id="shform" lay-filter="shform">
		<div class="layui-form-item">
			    <label class="layui-form-label">权重</label>
			    <div class="layui-input-inline">
			     	 <input type="text" id="weight" name="studentName" autocomplete="off"  class="layui-input">
			 	 </div>
 		 </div>
 		 	<div class="layui-form-item layui-form-text">
				    <label class="layui-form-label">备注</label>
				    <div class="layui-input-block">
				      <textarea id="bzu" name="content" placeholder="请输入备注" class="layui-textarea"></textarea>
				    </div>
				</div>
		<div class="layui-form-item">
		    <div class="layui-input-block">
		    <input type="button"  value="提交" class="layui-btn"  onclick="updseachBtn()">
		      <input type="button"  value="关闭" class="layui-btn"  onclick="askclosebtn()">
		    </div>
  		</div>
	    </form>
	</div>
</body>
</html>